#!/bin/bash

echo "===== Linux运维管理面板启动脚本 ====="

# 检查Node.js环境
if ! command -v node &> /dev/null; then
    echo "错误: 未安装Node.js，请先安装Node.js (https://nodejs.org/)"
    exit 1
fi

# 检查npm环境
if ! command -v npm &> /dev/null; then
    echo "错误: 未安装npm，请先安装npm"
    exit 1
fi

# 安装依赖
echo "正在检查依赖..."
if [ ! -d "./node_modules" ] || [ ! -d "./Linux-Backend/node_modules" ] || [ ! -d "./Linux-Frontend/node_modules" ]; then
    echo "正在安装依赖..."
    npm run install:all
fi

# 启动服务
echo "启动服务中..."
npm run dev

echo "======================================" 